package Java9_8.Test_1;

import java.util.ArrayList;
import java.util.List;

public class Conpany {
    private String name;//公司名称
    private String addess;//公司地址
    private String tel;//电话
    private String exp;//经营范围
    List list=new ArrayList();

    public Conpany(String name, String addess, String tel, String exp) {
        this.name = name;
        this.addess = addess;
        this.tel = tel;
        this.exp = exp;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddess() {
        return addess;
    }

    public void setAddess(String addess) {
        this.addess = addess;
    }

    public String getTel() {
        return tel;
    }

    public void setTel(String tel) {
        this.tel = tel;
    }

    public String getExp() {
        return exp;
    }

    public void setExp(String exp) {
        this.exp = exp;
    }
    //招聘员工(要求工号不能重复)
    public boolean add(Staff staff) {
        for (int i = 0; i < list.size(); i++) {
            if (staff.getJobNumber().equals(((Staff) (list.get(i))).getJobNumber())) {
                System.out.println("输入工号重复，添加失败");
                return false;
            }
        }
        list.add(staff);
        System.out.println("添加成功");
        return true;
    }
    //输出公司信息

    @Override
    public String toString() {
        return "公司{" +
                "名字='" + name + '\'' +
                ", 地址='" + addess + '\'' +
                ", 电话='" + tel + '\'' +
                ", 经营范围='" + exp + '\'' +
                '}';
    }
    //输出员工信息
    public void show(){
        for (int i=0;i<list.size();i++){
            if (list.get(i)==null){
                System.out.println("没有员工");
                break;
            }else if (list.get(i)!=null){
                System.out.println("员工信息如下");
                System.out.println(list.get(i));
            }
        }
    }
    //辞退员工方法
 public boolean delete(Staff staff){
    for (int i=0;i<list.size();i++){
        if (staff.getJobNumber().equals(((Staff)list.get(i)).getJobNumber())){
            list.remove(list.get(i));
            System.out.println("辞退员工成功");
            return true;
        }
        System.out.println("没有该员工");
    }       return false;
 }
 //统计公司人数
    public  void  rs(){
        System.out.println(list.size()+"人");
    }
    //获得公司薪水最高的员工
    public Staff  max(){
        Staff s=new Staff();
        for (int i=0;i<list.size();i++){
            if (((Staff)list.get(i)).getPay()>s.getPay()){
                s=(Staff) list.get(i);
            }
        }
            return s;
    }
}





